package com.wsx.ones.http;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wangshuaixin on 18/4/14.
 */
@RestController
public class HttpController {



    @RequestMapping(
            value = "/hello/test/{num}",
            method = {RequestMethod.GET}
    )
    public String hello(@PathVariable("num") int num) {
        boolean start = true;
        int i = 0;
        while (start) {
            System.out.println("hello");
            i ++;

            if (i >= num) {
                start = false;
            }
        }
        return "hello";
    }


    private static Map<String, String> map = new HashMap<>();
    @RequestMapping(
            value = "/hello/map/{num}",
            method = {RequestMethod.GET}
    )
    public String map(@PathVariable("num") int num) {
        boolean start = true;
        int i = 0;
        int starter = num;
        while (start) {
            starter++;
            map.put(String.valueOf(starter), String.valueOf(i));
            if (i >= 1000000) {
                start = false;
            }
            i ++;
        }
        return "hello:" + (1000000 + num);
    }
}
